#include <cstdio>
#include <iostream>
using namespace std;
#define N 100
int n, q, search[N];
struct Triangle
{
	long a;
	int n;
};
Triangle triangle[N];
struct Rectangle
{
	long a;
	long b;
	int n;
};
Rectangle rectangle[N];
struct Circle
{
	long r;
	int n;
};
Circle circle[N];
void input()
{
	char a;
	int i;
	cin >> n >> q;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		switch (a)
		{
		case 'T':
			cin >> triangle[i].a;
			triangle[i].n = i;
			break;
		case 'R':
			cin >> rectangle[i].a >> rectangle[i].b;
			rectangle[i].n = i;
			break;
		case 'C':
			cin >> circle[i].r;
			circle[i].n = i;
			break;
		}
	}
	for (i = 0; i < q; i++)
	{
		cin >> search[i];
		search[i]--;
	}
}
void output()
{
	int i;
	for (i = 0; i < q; i++)
	{
		if (triangle[search[i]].n == search[i] && triangle[search[i]].a != 0)
		{
			printf("Triangle %ld\n", triangle[search[i]].a);
		}
		if (rectangle[search[i]].n == search[i] && rectangle[search[i]].a != 0)
		{
			printf("Rectangle %ld %ld\n", rectangle[search[i]].a, rectangle[search[i]].b);
		}
		if (circle[search[i]].n == search[i] && circle[search[i]].r != 0)
		{
			printf("Circle %ld\n", circle[search[i]].r);
		}
	}
}
int main()
{
	input();
	output();
	return 0;
}